package controllers.job;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import play.Play;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.test.Fixtures;
import play.vfs.VirtualFile;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@OnApplicationStart
public class ImportSQL extends Job {
    public void doJob() {
/*        if(Play.mode.isDev() && !Play.id.equals("prod")) {
            *//*Fixtures.deleteDatabase();*//*
            Fixtures.deleteAllModels();
            VirtualFile vf = VirtualFile.fromRelativePath("/test/sql");
            List<VirtualFile> files = vf.list();
            Collections.sort(files, new Comparator<VirtualFile>() {
                @Override
                public int compare(VirtualFile o1, VirtualFile o2) {
                    return o1.getName().compareTo(o2.getName());
                }
            });

            for (VirtualFile file : files) {
                executeSQL(file);
            }
        }*/
    }

    private void executeSQL(VirtualFile file){
        Fixtures.executeSQL(file.getRealFile());
    }
}
